package com.finer.controller;

import com.finer.entity.ResponseMessage;
import com.finer.entity.document.FinerGoodUnit;
import com.finer.remote.document.FinerGoodUnitRemote;
import com.finer.service.FinerGoodUnitService;
import com.finer.util.BusinessType;
import com.finer.util.SysLogAnnotation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * 商品单位表(FinerGoodUnit)表控制层
 *
 * @author makejava
 * @since 2024-10-21 10:20:37
 */
@RestController
@CrossOrigin
@Slf4j
public class FinerGoodUnitController implements FinerGoodUnitRemote {
    /**
     * 服务对象
     */
    @Resource
    private FinerGoodUnitService finerGoodUnitService;

    @Override
    @SysLogAnnotation(operModul = "资料管理>>商品单位管理", operType = BusinessType.INSERT, operDesc = "新增商品单位")
    public ResponseMessage queryUnitByPage(@RequestParam Map map) {
        log.info("FinerGoodUnitController queryUnitByPage param:{}", map);
        ResponseMessage msg = finerGoodUnitService.selByPage(map);
        return msg;
    }

    @Override
    @SysLogAnnotation(operModul = "资料管理>>商品单位管理", operType = BusinessType.INSERT, operDesc = "新增商品单位")
    public ResponseMessage addUnit(@RequestBody FinerGoodUnit finerGoodUnit) {
        log.info("FinerGoodUnitController addUnit param:{}", finerGoodUnit);
        ResponseMessage msg = finerGoodUnitService.addUnit(finerGoodUnit);
        return msg;
    }

    @Override
    public ResponseMessage delUnitById(@RequestParam("id") Integer id) {
        log.info("FinerGoodUnitController delUnitById param:{}", id);
        ResponseMessage msg = finerGoodUnitService.delUnitById(id);
        return msg;
    }

    @Override
    public ResponseMessage updUnit(@RequestBody FinerGoodUnit finerGoodUnit) {
        log.info("FinerGoodUnitController updUnit param:{}", finerGoodUnit);
        ResponseMessage msg = finerGoodUnitService.update(finerGoodUnit);
        return msg;
    }

    @Override
    public ResponseMessage getUnitById(@RequestParam("id") Integer id) {
        log.info("FinerGoodUnitController getUnitById param:{}", id);
        ResponseMessage msg = finerGoodUnitService.queryById(id);
        return msg;
    }

    @RequestMapping("selUnitByPage")
    public ResponseMessage selUnitByPage(@RequestParam Map map) {
        log.info("FinerGoodUnitController selUnitByPage param:{}", map);
        ResponseMessage msg = finerGoodUnitService.selByPage(map);
        return msg;
    }
}

